Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

365
Visualizações
How do I fix 'Permission Denied' when I'm downloading a file from Firebase?

My project uses Firebase authentication and storage, and is built using React JS.

I have a file which is in the storage bucket at:

gs://myproject.appspot.com/myfolder/fileId

The download URL with token is:

https://firebasestorage.googleapis.com/v0/b/myproject.appspot.com/o/myfolder%2FfileId?alt=media&token=myToken

I want to be able to download the file in my app, so I have the following function within the Firebase class:

  doDownloadFile = (path: string) => {
    app
      .storage()
      .ref()
      .child(path)
      .getDownloadURL()
      .then((url) => {
        console.log(url);
      })
      .catch((error) => {
        console.log('Error: ', error);
      });
  };

(at the moment I'm just getting the URL, not downloading it).

The value of path is the downloadURL as given above (I've checked this by logging it at the top of the doDownloadFile function, and it's being passed in ok).

When I run this code, I get the following error:

Firebase Storage: User does not have permission to access 'https:/firebasestorage.googleapis.com/v0/b/myproject.appspot.com/o/myfolder%2FfileId?alt=media&token=myToken'. (storage/unauthorized)

On Googling I found 2 general solutions to this, but neither have worked for me.

The first is to set the security rules on the storage in the Firebase console. I've set this to:

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if request.auth!=null;
    }
  }
}

The second is to add the user firebase-storage@system.gserviceaccount.com as Storage Admin in the GCP console. This has been done.

Neither of these has made any difference, though. I still get the same error.

Where am I going wrong?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda